
<?php
/**
 * @package    Joomla.Tutorials
 * @subpackage Components
 * components/com_hello/hello.php
 * @link http://dev.joomla.org/component/option,com_jd-wiki/Itemid,31/id,tutorials:modules/
 * @license    GNU/GPL
*/

// no direct access

defined( '_JEXEC' ) or die( 'Restricted access' );

/*
$user = & JFactory::getUser();
if (!$user->authorize( 'com_weblinks', 'manage' )) {
	$mainframe->redirect( 'index.php', JText::_('ALERTNOTAUTH') );
}
*/
// Require the base controller
//$var = get_defined_constants();
//var_dump($var);
//var_dump('access point');
require_once( JPATH_COMPONENT_ADMINISTRATOR.DS.'controllers'.DS.'calendar.php' );
$var = JRequest::getVar( 'controller');
//var_dump($var);
// Require specific controller if requested
if($controller = JRequest::getVar( 'controller') ) {
	var_dump('here'.$controller.'there');
	$path = JPATH_COMPONENT_ADMINISTRATOR.DS.'controllers'.DS.$controller.'.php';
	var_dump($path);
    require_once( JPATH_COMPONENT_ADMINISTRATOR.DS.'controllers'.DS.$controller.'.php' );
}
//var_dump('point3');
if($controller == 'calendar') {
	//var_dump('controller3.4');
	JSubMenu::addEntry(JText::_('Events'), 'index.php?option=com_calendar');
	JSubMenu::addEntry(JText::_('Categories'), 'index.php?option=com_categories&section=com_calendar');
	JSubMenu::addEntry(JText::_('Config'), 'index.php?option=com_calendar&controller=config&view=config');
} else {
	/**
	* Joomla auto generates the submenu in 1.5RC
	*/
	JSubMenuHelper::addEntry(JText::_('Events'), 'index.php?option=com_calendar');
	JSubMenuHelper::addEntry(JText::_('Categories'), 'index.php?option=com_categories&section=com_calendar');
	JSubMenuHelper::addEntry(JText::_('Config'), 'index.php?option=com_calendar&controller=config');
	//var_dump('controller3.5');
	//JSubMenu::addEntry(JText::_('Events'), 'index.php?option=com_calendar');
	//var_dump('controller3.6');
	//JSubMenuHelper::addEntry(JText::_('test'), 'index.php?option=com_categories&section=com_calendar');
	//var_dump('controller3.7');
}
//var_dump('controller4');
// Create the controller
$classname    = 'calendarsController'.$controller;
$controller   = new $classname( );
//var_dump('controller5');
// Perform the Request task
//var_dump($controller);
$controller->execute( JRequest::getVar( 'task' ) );
//var_dump('controller6');
// Redirect if set by the controller
$controller->redirect();

?>

